﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartSpace.Core;

namespace SmartSpace.Data.AutoInput
{
    public class DateConvertor : IDataConvertor
    {
        public object Convert(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return DateTime.MinValue;
            }
            return System.Convert.ToDateTime(value);
        }

        public string Convert(object value)
        {
            if (value == null)
            {
                return string.Empty;
            }
            return ((DateTime)value).ToString("yyyy-MM-dd");
        }

        public void Default(User user, out string text, out object value)
        {
            text = string.Empty;
            value = null;
        }
    }
}
